package com.ruoyi.eqmonitor.temporary.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.eqmonitor.temporary.domain.Smdtv28;
import com.ruoyi.eqmonitor.temporary.dto.ExcelDto;
import com.ruoyi.eqmonitor.temporary.service.Smdtv28Service;
import com.ruoyi.eqmonitor.temporary.mapper.Smdtv28Mapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author YR
* @description 针对表【smdtv_28】的数据库操作Service实现
* @createDate 2022-12-27 16:15:59
*/
@Service
public class Smdtv28ServiceImpl extends ServiceImpl<Smdtv28Mapper, Smdtv28>
    implements Smdtv28Service{

    @Resource
    private Smdtv28Mapper smdtv28Mapper;

    @Override
    public Map<String, Object> getInfoByWtdh(List<ExcelDto> value) {
        Map<String, Object> maps = new HashMap<>();
        //根据questionType进行分组
        Map<String, List<ExcelDto>> collect1 = value.stream().collect(Collectors.groupingBy(ExcelDto::getQuestionType));
        for (Map.Entry<String, List<ExcelDto>> entry1 : collect1.entrySet()) {
            List<String> dotList = new ArrayList<>();
            List<ExcelDto> value1 = entry1.getValue();
            for (ExcelDto excelDto : value1) {
                dotList.add(excelDto.getDot());
            }
            List<Smdtv28> list = smdtv28Mapper.getInfoByWtdh(dotList);
            maps.put(entry1.getKey(), list);
        }
        return maps;
    }
}




